<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionController::TestCase::Behavior::ClassMethods</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionController::TestCase::Behavior::ClassMethods 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/actionpack/lib/action_controller/test_case_rb.html">actionpack/lib/action_controller/test_case.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-controller_class">controller_class</a>,
              </li>
            
              
              <li>
                <a href="ClassMethods.html#method-i-controller_class-3D">controller_class=</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>D</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-determine_default_controller_class">determine_default_controller_class</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>P</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-prepare_controller_class">prepare_controller_class</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="ClassMethods.html#method-i-tests">tests</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-controller_class">
            
              <b>controller_class</b>()
            
            <a href="ClassMethods.html#method-i-controller_class" name="method-i-controller_class" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-controller_class_source')" id="l_method-i-controller_class_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/474864a30acb3d687652428b8ad3efad86460b9b/actionpack/lib/action_controller/test_case.rb#L434" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-controller_class_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/test_case.rb, line 434</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">controller_class</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">current_controller_class</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">_controller_class</span>
    <span class="ruby-identifier">current_controller_class</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">controller_class</span> = <span class="ruby-identifier">determine_default_controller_class</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-controller_class-3D">
            
              <b>controller_class=</b>(new_class)
            
            <a href="ClassMethods.html#method-i-controller_class-3D" name="method-i-controller_class-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-controller_class-3D_source')" id="l_method-i-controller_class-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/474864a30acb3d687652428b8ad3efad86460b9b/actionpack/lib/action_controller/test_case.rb#L429" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-controller_class-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/test_case.rb, line 429</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">controller_class=</span>(<span class="ruby-identifier">new_class</span>)
  <span class="ruby-identifier">prepare_controller_class</span>(<span class="ruby-identifier">new_class</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">new_class</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">_controller_class</span> = <span class="ruby-identifier">new_class</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-determine_default_controller_class">
            
              <b>determine_default_controller_class</b>(name)
            
            <a href="ClassMethods.html#method-i-determine_default_controller_class" name="method-i-determine_default_controller_class" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-determine_default_controller_class_source')" id="l_method-i-determine_default_controller_class_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/474864a30acb3d687652428b8ad3efad86460b9b/actionpack/lib/action_controller/test_case.rb#L442" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-determine_default_controller_class_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/test_case.rb, line 442</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">determine_default_controller_class</span>(<span class="ruby-identifier">name</span>)
  <span class="ruby-identifier">determine_constant_from_test_name</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">constant</span><span class="ruby-operator">|</span>
    <span class="ruby-constant">Class</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">constant</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">constant</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Metal</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-prepare_controller_class">
            
              <b>prepare_controller_class</b>(new_class)
            
            <a href="ClassMethods.html#method-i-prepare_controller_class" name="method-i-prepare_controller_class" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-prepare_controller_class_source')" id="l_method-i-prepare_controller_class_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/474864a30acb3d687652428b8ad3efad86460b9b/actionpack/lib/action_controller/test_case.rb#L448" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-prepare_controller_class_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/test_case.rb, line 448</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">prepare_controller_class</span>(<span class="ruby-identifier">new_class</span>)
  <span class="ruby-identifier">new_class</span>.<span class="ruby-identifier">send</span> <span class="ruby-value">:include</span>, <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">TestCase</span><span class="ruby-operator">::</span><span class="ruby-constant">RaiseActionExceptions</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-tests">
            
              <b>tests</b>(controller_class)
            
            <a href="ClassMethods.html#method-i-tests" name="method-i-tests" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Sets the controller class name. Useful if the name can’t be inferred from
test class. Normalizes <code>controller_class</code> before using.</p>

<pre>tests WidgetController
tests :widget
tests 'widget'</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-tests_source')" id="l_method-i-tests_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/474864a30acb3d687652428b8ad3efad86460b9b/actionpack/lib/action_controller/test_case.rb#L418" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-tests_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_controller/test_case.rb, line 418</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">tests</span>(<span class="ruby-identifier">controller_class</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">controller_class</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>, <span class="ruby-constant">Symbol</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">controller_class</span> = <span class="ruby-node">&quot;#{controller_class.to_s.camelize}Controller&quot;</span>.<span class="ruby-identifier">constantize</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Class</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">controller_class</span> = <span class="ruby-identifier">controller_class</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;controller class must be a String, Symbol, or Class&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    